home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_5.lha
/
8_5
/
nstdio.h
< prev
next >
Wrap
Text File
|
1993-08-08
|
5KB
|
160 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ Exercise 8.5
/ <stdio.h>
/ Implementation of standard I/O
/ using the stream I/O functions.
ifndef STDIO_H
define STDIO_H
include <stream.h>
include <stdarg.h>
undef FILE /* DELETE */
undef _bufend /* DELETE */
undef _bufsiz /* DELETE */
undef getc /* DELETE */
undef putc /* DELETE */
undef getchar /* DELETE */
undef putchar /* DELETE */
undef clearerr /* DELETE */
undef feof /* DELETE */
undef ferror /* DELETE */
undef fileno /* DELETE */
undef EOF /* DELETE */
undef NULL /* DELETE */
undef BUFSIZ /* DELETE */
undef stdin /* DELETE */
undef stdout /* DELETE */
undef stderr /* DELETE */
undef L_ctermid /* DELETE */
undef L_cuserid /* DELETE */
undef P_tmpdir /* DELETE */
undef L_tmpnam /* DELETE */
undef _NFILE /* DELETE */
undef _SBFSIZ /* DELETE */
undef _IOFBF /* DELETE */
undef _IOREAD /* DELETE */
undef _IOWRT /* DELETE */
undef _IONBF /* DELETE */
undef _IOMYBUF /* DELETE */
undef _IOEOF /* DELETE */
undef _IOERR /* DELETE */
undef _IOLBF /* DELETE */
undef _IORW /* DELETE */
define FILE xFILE /* DELETE */
define BUFSIZ xBUFSIZ /* DELETE */
define EOF xEOF /* DELETE */
define clearerr xclearerr /* DELETE */
define fclose xfclose /* DELETE */
define feof xfeof /* DELETE */
define ferror xferror /* DELETE */
define fflush xfflush /* DELETE */
define fgetc xfgetc /* DELETE */
define fgets xfgets /* DELETE */
define fileno xfileno /* DELETE */
define fopen xfopen /* DELETE */
define fprintf xfprintf /* DELETE */
define fputc xfputc /* DELETE */
define fputs xfputs /* DELETE */
define fread xfread /* DELETE */
define freopen xfreopen /* DELETE */
define fscanf xfscanf /* DELETE */
define fwrite xfwrite /* DELETE */
define getc xgetc /* DELETE */
define getchar xgetchar /* DELETE */
define gets xgets /* DELETE */
define printf xprintf /* DELETE */
define putc xputc /* DELETE */
define putchar xputchar /* DELETE */
define scanf xscanf /* DELETE */
define setbuf xsetbuf /* DELETE */
define sprintf xsprintf /* DELETE */
define sscanf xsscanf /* DELETE */
define stderr xstderr /* DELETE */
define stdin xstdin /* DELETE */
define stdout xstdout /* DELETE */
define ungetc xungetc /* DELETE */
define vfprintf xvfprintf /* DELETE */
define vfscanf xvfscanf /* DELETE */
define vprintf xvprintf /* DELETE */
define vscanf xvscanf /* DELETE */
define vsprintf xvsprintf /* DELETE */
define vsscanf xvsscanf /* DELETE */
lass FILE
open_mode mode;
union
{
istream *in;
ostream *out;
};
streambuf *sb;
char unbuf;
ublic:
FILE(streambuf *st, open_mode m);
FILE(istream *is);
FILE(ostream *os);
~FILE();
// open and close FILEs
friend FILE *fopen(const char *file,
const char *mode);
friend FILE *freopen(const char *file,
const char *mode, FILE *f);
friend int fclose(FILE *);
// input functions
friend int getc(FILE *);
friend int ungetc(int const, FILE *);
friend int fgetc(FILE *);
friend int getchar();
friend char *gets(char *buf);
friend char *fgets(char *buf, int sz, FILE *);
friend int fread(void *buf, unsigned int sz,
unsigned int n, FILE *);
friend int scanf(const char *fmt, ...);
friend int fscanf(FILE *, const char *fmt, ...);
friend int sscanf(const char *buf,
const char *fmt, ...);
friend int vscanf(const char *fmt, va_list vl);
friend int vfscanf(FILE *f,
const char *fmt, va_list vl);
friend int vsscanf(const char *str,
const char *fmt, va_list vl);
// output functions
friend int putc(int c, FILE *);
friend int putchar(int c);
friend int fputc(int c, FILE *);
friend int puts(const char *buf);
friend int fputs(const char *buf, FILE *);
friend int fwrite(void *buf, unsigned int sz,
unsigned int n, FILE *);
friend int printf(const char *fmt, ...);
friend int fprintf(FILE *, const char *fmt, ...);
friend int sprintf(char *buf, const char *fmt, ...);
friend int vprintf(const char *fmt, va_list);
friend int vfprintf(FILE *,
const char *fmt, va_list);
friend int vsprintf(char *buf,
const char *fmt, va_list);
// status manipulation and checking
friend int ferror(FILE *);
friend int feof(FILE *);
friend void clearerr(FILE *);
// buffering manipulation
friend void setbuf(FILE *, char *);
friend int fflush(FILE *);
;
define NULL 0
onst int EOF = -1;
onst int BUFSIZ = 1024;
xtern FILE *stdin, *stdout, *stderr;
endif /* STDIO_H */